/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.view.wizard.analysis;

import javax.swing.JPanel;
import systole.domain.clinicalInformation.ClinicalInformation;
import systole.domain.persons.Patient;
import systole.view.wizard.PageController;
import systole.view.wizard.WizardResult;

/**
 *
 * @author jmj
 */
public class ThirdPageController extends PageController {

    public static final String KEY = "THIRD_PAGE";
    private JPnlPatientInfo page;

    @Override
    public String validatePage() {
        return this.page.validateConditions();
    }

    @Override
    public String getKey() {
        return KEY;
    }

    @Override
    public boolean hasNext() {
        return false;
    }

    @Override
    public boolean hasLast() {
        return true;
    }

    @Override
    public JPanel getPage() {
        if (this.page == null) {
            this.page = new JPnlPatientInfo();
        }
        return page;
    }

    @Override
    public boolean pageInitialized() {
        return this.page != null;
    }

    @Override
    public boolean canDoFinish() {
        return true;
    }

    @Override
    public boolean canViewSummary() {
        return true;
    }

    @Override
    public WizardResult loadResult(WizardResult result) {
        ClinicalInformation clinicalInformation = this.page.getClinicalInformation();
        result.putObjet("clinicalInfo", clinicalInformation);
        return result;
    }

    @Override
    public void setPreviousStepData(WizardResult result) {
        Patient patient = (Patient) result.getObject("patient");
        if (patient!=null){
            this.page.loadLastClinicalInfo(patient);
        }
    }
}
